#ifndef __MYDBOP_H__
#define __MYDBOP_H__

// #include <myhead.h>
#include<stdio.h>
#include<errno.h>
#include<string.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<fcntl.h>
#include<unistd.h>
#include<pwd.h>
#include<grp.h>
#include<time.h>
#include<dirent.h>
// #include<pthread.h>
#include<semaphore.h>
#include<sys/ipc.h>
#include<sys/msg.h>
#include<sys/shm.h>
#include<sys/sem.h>
#include<sys/socket.h>
#include<netinet/ip.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include <signal.h>
#include <wait.h>
#include <time.h>
#include <sys/time.h>

#include <sqlite3.h>
#include "../inc/myprotocol.h"

typedef struct _login_info
{
    char usrname[32];
    char password[32];
    int if_true;
} login_info_t;

typedef struct _staff_info
{
    char name[32];
    int old;
    char department[32];
    int salary;
} staff_info_t;

typedef struct _search_info
{
    char name[32];
    staff_info_t staff_info;
    int if_true;
} search_info_t;

typedef struct _mylist
{
    char data[32];
    struct _mylist *next;
} mylist_t;
typedef struct _mylist_nb
{
    mylist_t *last;
    int count;
} mylist_nb_t;

sqlite3 *db_init();
int db_insert_usr_info(sqlite3 *db, char *name, char *usrname, char *password);
int call_back_verify(void *login_info, int ncolumn, char **f_value, char **f_name);
int call_back_search(void *search_info, int ncolumn, char **f_value, char **f_name);
int db_verify(sqlite3 *db, login_info_t login_info);
int db_search(sqlite3 *db, search_info_t *search_info);

int db_insert_staff_info(sqlite3 *db, trans_dbinfo_t staff_info);
int db_modify_staff_info(sqlite3 *db, trans_dbinfo_t staff_info);
int db_delete_staff_info(sqlite3 *db, search_info_t *search_info);

int call_back_select_all(void *point, int ncolumn, char **f_value, char **f_name);
int db_select_all(sqlite3 *db, int connect_fd);
int db_verify_manager(sqlite3 *db, login_info_t login_info);

int register_usr(trans_usrinfo_t *register_info, sqlite3 *db);
int delete_usr(trans_usrinfo_t *register_info, sqlite3 *db);

int call_back_select_usr(void *point, int ncolumn, char **f_value, char **f_name);
int db_select_allusr(sqlite3* db,int connect_fd);

#endif